<?php
namespace User\Form;

use Zend\Form\Form;
use Zend\Form\Element;
use Zend\ServiceManager\ServiceManager;
use User\Model\RoleTable;


class UserInRoleForm extends Form
{
	protected $roleTable;
	
	public function __construct(RoleTable $roleTable, $name = null)
	{
		$this->roleTable = $roleTable;
		
		$this->setAttribute('accept-charset', 'utf-8');
		
		parent::__construct('UserInRole');
		
		$uid = new Element\Hidden('uid');
		
		
		
		$result = $this->roleTable->fetchAll();
		
		$val = array();
		
		foreach ($result as $row)
		{
			$val[$row['rid']] = $row['name'];
		}
		
		$rid = new Element\Select('rid');
		$rid->setLabel('Role Name');
		$rid->setValueOptions($val);
		$rid->setEmptyOption('-- Select role name!--');
		
		$submit = new Element\Submit('submit');
		$submit->setValue('Submit change');
		
		$this->add($uid)->add($rid)->add($submit);
	}
}

?>